package Dao.impl;

import Dao.BaseDao;
import Dao.UserDao;
import pojo.User;

public class UserDaoimpl extends BaseDao implements UserDao {
    @Override
    public User queryUsername(String name) {
        String sql = "select id,username,password,email from books where username = ? ";
        return queryForOne(User.class,sql,name);
    }

    @Override
    public User queryUsernameAndPsw(String name, String password) {
        String sql = "select id,username,password from books where username=? and password= ? ";
        return queryForOne(User.class,sql,name,password);
    }

    @Override
    public int saveUser(User user) {
        String sql = "insert into books (username,password,email) values(?,?,?)";
        return  updateForOne(sql, user.getUsername(), user.getPassword(), user.getEmail());
    }

}
